package com.traveliko.controller;

import com.traveliko.model.BarChart;
import com.traveliko.model.PieChart;
import com.traveliko.service.ChannelManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

/**
 * Created by Yasir Shabbir on 2/5/2017.
 */

/*
This is Rest based Controller and it's method provide JSON Response.
 */
@org.springframework.web.bind.annotation.RestController
public class RestController {


    private final ChannelManager channelManager;

    @Autowired
    public RestController(ChannelManager channelManager) {
        this.channelManager = channelManager;
    }

    /*
    This is Request Handler Method used for to create and return the record
    for PieChart using Rest web services in JSON format.
    Currently it's return Dummy data and will be updated as BJorn said the Channel Manager
     */
    @RequestMapping(value = "pieChartRecords", method = RequestMethod.GET)
    public ResponseEntity<List<PieChart>> getPieChartRecords() {
        List<PieChart> pieCharts = channelManager.getPieChartDummyRecords();
        return new ResponseEntity<List<PieChart>>(pieCharts, HttpStatus.OK);
    }


    /*
  This is Request Handler Method used for to create and return the record
  for Bar Chart using Rest web services in JSON format.
  Currently it's return Dummy data and will be updated as BJorn said the Channel Manager
   */
    @RequestMapping(value = "barChartRecords", method = RequestMethod.GET)
    public ResponseEntity<List<BarChart>> getBarChartRecords() {


        List<BarChart> barCharts = channelManager.getBarChartDummyRecords();

        return new ResponseEntity<List<BarChart>>(barCharts, HttpStatus.OK);
    }


}
